<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Articles extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('articles');
        $table->addColumn('title', 'string',array('limit'  =>  255,'default'=>'','comment'=>'文章标题'))
            ->addColumn('author', 'string',array('limit'  =>  50,'default'=>'','comment'=>'作者'))
            ->addColumn('explain', 'string',array('limit'  =>  255,'default'=>'','comment'=>'文章介绍'))
            ->addColumn('cover', 'string',array('limit'  =>  255,'default'=>'','comment'=>'封面地址'))
            ->addColumn('content', 'text',array('default'=>'','comment'=>'文章内容'))
            ->addColumn('status', 'integer',array('limit'  =>  1,'default'=>1,'comment'=>'状态1正常  2下架'))
            ->addColumn('type', 'integer',array('limit'  =>  11,'default'=>0,'comment'=>'文章类型'))
            ->addColumn('create_time', 'datetime',array('default'=>null,'comment'=>'创建时间'))
            ->addColumn('update_time', 'datetime',array('default'=>null,'comment'=>'更新时间'))
            ->addColumn('delete_time', 'datetime',array('default'=>null,'comment'=>'删除时间'))
            ->create();
    }
}
